#   导入相关的第三方库
from GoogleFreeTrans import Translator
def trans0(text):
    # 调用translator，src的参数值是待翻译的语言，dest的参数值是翻译后的语言
    translator0 = Translator.translator(src='en', dest='zh-CN')
    return translator0.translate(text)
def trans1(text):
    translator1 = Translator.translator(src='zh-CN', dest='en')
    return translator1.translate(text)
if __name__ == '__main__':
    choice = input('0代表英译汉，1代表汉译英，请选择：')
    # 写一个死循环，以便于可以一直翻译
    while True:
        if choice == '0':
            text = input('请输入你要翻译的英文：')
            result = trans0(text)
            print(result)
        elif choice == '1':
            text = input("请输入你要翻译的中文：")
            result = trans1(text)
            print(result)
        elif choice == 'q':
            print("程序退出")
            break
        else:
            # print("你输入的选择有误，请重新输入")
            choice = input("你输入的选择有误，请重新输入:")

'''
I am going to study hard, and fulfill my dream
I want to be a pilot when I grow up
knowledge has no limit
My experience has taught me that being a life long learner is very much part of who I am.
长大以后我想成为马云那样的老板
我想通过互联网创业
程序员会掉发吗
互联网行业就业前景好不好
'''





# from googletrans import Translator
# def trans(text):
#     translator = Translator()
#     return translator.translate(text,src='en', dest='en').text
#
# if __name__ == '__main__':
#     res = trans("我是最帅的")
#     print(res)

'''
from googletrans import Translator

def trans(text):
    translator = Translator()
    return translator.translate(text, dest='zh-CN').text
    
if __name__ == '__main__':
    res = trans("Thank for reading")
    print(res)
'''